<template>
	<view class="df  jcsb" style="margin-left: -20rpx;">
		<view class="">
			<item @changeGoods="changeGoods" v-if="index%2==0" @changeCarList="changeCarList" :goodsCarList="goodsCarList" type="left" :item="item" v-for="(item,index) in flowList" :key="index" @chooseSkuShow="chooseSkuShow($event,index,'left')"  @handleLogin="handleLogin" ></item>
		</view>
		<view class="">
			<item v-if="index%2==1" @changeGoods="changeGoods" @changeCarList="changeCarList" :goodsCarList="goodsCarList" type="left" :item="item" v-for="(item,index) in flowList" :key="index" @chooseSkuShow="chooseSkuShow($event,index,'left')"  @handleLogin="handleLogin" ></item>
		</view>
		
		<!-- <item @changeCarList="changeCarList" :goodsCarList="goodsCarList" type="left" :item="item" v-for="(item,index) in leftList" :key="index" @chooseSkuShow="chooseSkuShow($event,index,'left')"  @handleLogin="handleLogin" ></item> -->
		<!-- <u-waterfall add-time="0" v-model="flowList" ref="uWaterfall">
			<template v-slot:left="{leftList}">
				<item @changeCarList="changeCarList" :goodsCarList="goodsCarList" type="left" :item="item" v-for="(item,index) in leftList" :key="index" @chooseSkuShow="chooseSkuShow($event,index,'left')"  @handleLogin="handleLogin" ></item>
			</template>
			<template v-slot:right="{rightList}">
				<item @changeCarList="changeCarList" :goodsCarList="goodsCarList" type="left" :item="item" v-for="(item,index) in rightList" :key="index" @chooseSkuShow="chooseSkuShow($event,index,'right')"  @handleLogin="handleLogin" ></item>
			</template>
		</u-waterfall> -->
		<SkuPopup @changeCarList="changeCarList" :goodsCarList="goodsCarList" @change="changeSku" v-model="showSku" :info="skuInfo"></SkuPopup>
	</view>
</template>


<script>
	import item from './item.vue'
	export default {
		name: "goodsList",
		components:{item},
		props: {
			flowList: {
				default: () =>[],
				type: Array
			},
			goodsCarList: {
				default: () =>[],
				type: Array
			},
		},
		data() {
			return {
				showSku:false,
				token:'',
				skuInfo:{},
				type:'',
				index:0
			};
		},
		mounted() {
			this.token = uni.getStorageSync('token')
		},
			
		methods:{
			copyFlowList(){
				this.$refs.uWaterfall.copyFlowList
			},
			changeCarList(e,index,type){
				this.$emit('changeCarList',e)
			},
			splitData(){
			},
			// sku的修改，这里需要修改外部商品列表
			changeSku(info){
				this.$emit('changeSku',info)
				// if(this.type=='left'){
				// 	 item = this.$refs.uWaterfall.leftList[this.index] = info
				// }else{
				// 	 item = this.$refs.uWaterfall.rightList[this.index] = info
				// }
			},
			changeGoods(info){
				this.$emit('changeSku',info)
			},
			chooseSkuShow(item,index,type){
				this.skuInfo = item
				this.type = type
				this.index = index
				this.showSku = true
			},
			refresh(){
				this.token = uni.getStorageSync('token')
				this.$refs.itemRight.tokenItem = uni.getStorageSync('token')
				this.$refs.itemLeft.tokenItem = uni.getStorageSync('token')
			},
			handleLogin(){
				this.$emit('handleLogin')
			}
		}
	}
</script>

<style scoped lang="scss">

</style>